#include "dialog.h"
#include "QGraphicsDropShadowEffect"
#include "ui_dialog.h"
#include <QPainter>
#include <QBitmap>
#include <QDesktopWidget>
#include <QPropertyAnimation>
#include <QTime>

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    setFixedSize(this->width(), this->height());
    //取消标题栏
    setWindowFlags(Qt :: FramelessWindowHint | Qt :: Dialog);
    setAttribute(Qt::WA_TranslucentBackground, true);
}

Dialog::~Dialog()
{
    delete ui;
}
// 延时器，等待 msec 秒，用于动画中的等待时间
bool Delay_MSec(unsigned int msec)      // 程序等待 msec 毫秒
{
    QTime time;
    time.start();
    while(time.elapsed() < msec)            //等待时间流逝 msec 毫秒
    QCoreApplication::processEvents();   //处理事件
    return true ;
}

void Dialog::on_pushButton_clicked()
{
    QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
    animation->setDuration(500);
    animation->setStartValue(1);
    animation->setEndValue(0);
    animation->start();
    Delay_MSec(500);
    this->hide();
}

